package com.woniu.hospital.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.woniu.hospital.domain.SurgicalDesc;
import com.woniu.hospital.service.ISurgicalDescService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 手术详情表Controller
 * 
 * @author wolf-six
 * @date 2023-02-15
 */
@RestController
@RequestMapping("/surgical_desc")
public class SurgicalDescController extends BaseController
{
    @Autowired
    private ISurgicalDescService surgicalDescService;

    /**
     * 查询手术详情表列表
     */
    @RequiresPermissions("hospital:surgical_desc:list")
    @GetMapping("/list")
    public TableDataInfo list(SurgicalDesc surgicalDesc)
    {
        startPage();
        List<SurgicalDesc> list = surgicalDescService.selectSurgicalDescList(surgicalDesc);
        return getDataTable(list);
    }

    /**
     * 导出手术详情表列表
     */
    @RequiresPermissions("hospital:surgical_desc:export")
    @Log(title = "手术详情表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SurgicalDesc surgicalDesc)
    {
        List<SurgicalDesc> list = surgicalDescService.selectSurgicalDescList(surgicalDesc);
        ExcelUtil<SurgicalDesc> util = new ExcelUtil<SurgicalDesc>(SurgicalDesc.class);
        util.exportExcel(response, list, "手术详情表数据");
    }

    /**
     * 获取手术详情表详细信息
     */
    @RequiresPermissions("hospital:surgical_desc:query")
    @GetMapping(value = "/{surgicalDescid}")
    public AjaxResult getInfo(@PathVariable("surgicalDescid") Long surgicalDescid)
    {
        return success(surgicalDescService.selectSurgicalDescBySurgicalDescid(surgicalDescid));
    }

    /**
     * 新增手术详情表
     */
    @RequiresPermissions("hospital:surgical_desc:add")
    @Log(title = "手术详情表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SurgicalDesc surgicalDesc)
    {
        return toAjax(surgicalDescService.insertSurgicalDesc(surgicalDesc));
    }

    /**
     * 修改手术详情表
     */
    @RequiresPermissions("hospital:surgical_desc:edit")
    @Log(title = "手术详情表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SurgicalDesc surgicalDesc)
    {
        return toAjax(surgicalDescService.updateSurgicalDesc(surgicalDesc));
    }

    /**
     * 删除手术详情表
     */
    @RequiresPermissions("hospital:surgical_desc:remove")
    @Log(title = "手术详情表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{surgicalDescids}")
    public AjaxResult remove(@PathVariable Long[] surgicalDescids)
    {
        return toAjax(surgicalDescService.deleteSurgicalDescBySurgicalDescids(surgicalDescids));
    }
}
